﻿﻿@model IEnumerable<TeamOPSchoolCup.Domain.POCO.Region>
@{
    ViewBag.Title = "Index";
}

@section region{
    <link rel="Stylesheet" href="@Url.Content("~/Content/css/Region.css")" type="text/css" />
}

<h1 class="wrappertitel">
    @{if (ViewBag.ParentName != null)
      {
        <text>@ViewBag.ParentName</text>
      }
      else
      {
          <text>Region</text>
      }}

</h1>
<div id="add">
    <p id="add1">
        <a title="Click here to add one region" href="@Url.Action("Create", new { parentId = ViewBag.RegionId})">
            <img class="addlogo" src="@Url.Content("~/Content/images/addlogo.png")" alt="add" />
        <span>Add One</span></a>
    </p>
    <p id="add2">
        <a title="Click here to import regions" href="@Url.Action("AddRegions")">
            <img class="addlogo" src="@Url.Content("~/Content/images/addslogo.png")" alt="add More" />
        <span>Import Regions</span></a>
    </p>
</div>


<table id="regionTable">
    <tr id="header">
        <th class="head" id="numberHeader" />
        <th class="head">Region</th>
        <th class="head"># Subregions</th>
        <th />
    </tr>
    @{int index = 1;}
    @foreach (var region in Model)
    {
        <tr>
            <td class="number">
                @index
            </td>
            <td class="infocell">
                @Html.ActionLink(region.Name, "Index", new { regionId = region.RegionId })
            </td>
            <td class="infocell">@TeamOPSchoolCup.Domain.Services.RegionService.GetChildren(region).Count()</td>
            <td class="last">
                @Html.ActionLink("Edit", "Edit", new { id = region.RegionId })
            </td>
            @{ index += 1; }
        </tr>
    }  
</table>
<div id="back">@Html.ActionLink("Go back to Parent Region", "Index", new { regionId = @ViewBag.ParentId })</div>

